package com.lf.cloud.comm.dao;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.lf.cloud.comm.modal.dto.TagsDto;
import com.lf.cloud.comm.modal.pojo.GrabAimeishishangInf;
import com.lf.cloud.comm.webutils.CommMethod;

public class GrabAimeishishangInfDao extends GrabAimeishishangInf {
	
	
	public static GrabAimeishishangInfDao me = new GrabAimeishishangInfDao();
	
	
	
	
	public void insert(GrabAimeishishangInf GrabUploadInf){
		GrabUploadInf.save();
	}
	
	
	public void batchAdd(List<GrabAimeishishangInf> GrabUploadInf , int batchSize ){
		int[] batchSave = Db.batchSave(GrabUploadInf, batchSize);
	}
	
	
	
	public Page<GrabAimeishishangInf> geetGrabAimeishishangInfPage(int pageNumber , int pageSize , String expandName , String fileType , String reateId){
		String select = "SELECT *";
		String sql = " FROM "+CommMethod.getTbaleName("GrabAimeishishangInf") +" WHERE is_delete='0' ";
		
		if(StringUtils.isNotEmpty(expandName)){
			sql += " AND expand_name = '"+expandName+"'";
		}
		if(StringUtils.isNotEmpty(fileType)){
			sql += " AND file_type = '"+fileType+"'";
		}
		if(StringUtils.isNotEmpty(reateId)){
			sql += " AND reate_id = '"+reateId+"'";
		}
		return dao.paginate(pageNumber, pageSize, select, sql);
	}
	
	
	
	public String geetFileTypeList(){
		return "";
	}
	
	
	
	public List<Record> inintdata(){
		String sql = "SELECT  title_id , title_name, COUNT(title_id)  FROM lexy_grab_aimeishishang_inf GROUP BY title_id ";
		return Db.find(sql);
	}
	
	
	
	public List<GrabAimeishishangInf> geetGrabAimeishishangInfByTitleId(String titleId ){
		String sql = "SELECT  *  FROM lexy_grab_aimeishishang_inf  WHERE title_id = '"+titleId+"'";
		return dao.find(sql);
	}
	
	
	
	public List<GrabAimeishishangInf> geetGrabAimeishishangInf_GroupBy(String tagName){
		String sql = "SELECT  *  FROM lexy_grab_aimeishishang_inf  WHERE title_name like '%"+tagName+"%' and is_delete='0' group by title_id";
		return dao.find(sql);
	}
	
	
	
	
	
	
	
	
	
	
	

}
